<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title>第十四课 BOM</title>
</head> 
<body>
    <button id="btn1">按钮</button>
    <script>

        var fn1 = function(){
            console.log('星星课堂真好');
            timer = setTimeout(fn1,1000);
        }

        var timer = setTimeout(fn1,1000);

        // var timer1 = setTimeout(function(){
        //     alert('星星课堂');
        // },5000);

        // var timer2 = setInterval(function(){
        //     console.log('xingxingclassroom');
        // },1000);

        var btn1 = document.getElementById('btn1');
        btn1.addEventListener('click',function(){
            clearTimeout(timer);
        });
    </script>
</body> 
</html>